<%@ page contentType="text/html;charset=UTF-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ taglib prefix="tags" tagdir="/WEB-INF/tags" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn"%>
<%@taglib prefix="shiro" uri="http://shiro.apache.org/tags" %>
<c:set var="ctx" value="${pageContext.request.contextPath}"/>
<html>
<head>
	<title>消息管理</title>
	<link rel="stylesheet" href="${ctx}/static/css/datepicker.css" />
	<link rel="stylesheet" href="${ctx}/static/css/jquery-ui.min.css" />
    <script src="${ctx}/static/js/jquery-ui.min.js"></script>
    <script src="${ctx}/static/js/date-time/bootstrap-datepicker.js"></script>
    <script src="${ctx}/static/js/bootstrap-tag.js"></script>
</head>
<body>	
	
	<div class="main-content-inner">
	
		<div class="breadcrumbs" id="breadcrumbs">
			
			<script type="text/javascript">
				try{ace.settings.check('breadcrumbs' , 'fixed')}catch(e){}
			</script>
	
			<ul class="breadcrumb">
				<li>
					<i class="ace-icon fa fa-home home-icon"></i>
					<a href="${ctx}/welcome">主页</a>
				</li>
				<li class="active">消息</li>
			</ul>
			
			<div class="nav-search" id="nav-search">
				<form class="form-search" action="${ctx}/msg/list" method="GET">
					时间:<span class="input-icon">
							<span class="input-daterange input-group">
								<input type="text" style="width:100px;" id="datetimeStart" class="input-sm form-control" name="search_GT_createdate" value="${param.search_GT_createdate}" >
								<span class="input-group-addon" style="width:30px;">
									<i class="fa fa-exchange"></i>
								</span>
								<input type="text" style="width:100px;" id="datetimeEnd" class="input-sm form-control" name="search_LTE_createdate" value="${param.search_LTE_createdate}" >
							</span>
					</span>
					
					消息类型:
					<span class="input-icon">
					    <select class="chosen-select form-control" name="search_EQ_type" data-placeholder="请选择状态">
					        <option value="0" selected="selected">请选择</option>
							<option value="1" <c:if test="${param.search_EQ_type eq 1 }">selected="selected"</c:if>>消息推送</option>
							<option value="2" <c:if test="${param.search_EQ_type eq 2 }">selected="selected"</c:if>>消息通知</option>
							<!-- <option value="3" <c:if test="${param.search_EQ_type eq 3 }">selected="selected"</c:if>>维护通知</option> -->
						</select>
					</span>
					
					推送用户:
					<span class="input-icon">
					    <select class="chosen-select form-control" name="search_EQ_device" data-placeholder="请选择状态">
					        <option value="" selected="selected">请选择</option>
							<option value="1" <c:if test="${param.search_EQ_device eq '1' }">selected="selected"</c:if>>android</option>
							<option value="2" <c:if test="${param.search_EQ_device eq '2' }">selected="selected"</c:if>>IOS</option>
							<option value="4" <c:if test="${param.search_EQ_device eq '4' }">selected="selected"</c:if>>全网用户</option>
							<option value="5" <c:if test="${param.search_EQ_device eq '5' }">selected="selected"</c:if>>离线用户</option>
						</select>
					</span>
					查询:
					<span class="input-icon">
						<span class="input-group">
							<input type="text" autocomplete="off" name="search_LIKE_msg" placeholder="消息内容" class="nav-search-input" id="nav-search-input" autocomplete="off" value="${param.search_LIKE_msg}" />
						</span>	
					</span>
					<input type="button" value="搜索" onclick = "$('.form-search').submit();" />
				</form>
			</div>
	
		</div>	
		
		<div class="page-content">
			
			<c:if test="${not empty message}">
				<div id="message" class="alert alert-success"><button data-dismiss="alert" class="close">×</button>${message}</div>
			</c:if>	
			
			<div class="page-header">
				<h1>
					消息
					<small>
						<i class="ace-icon fa fa-angle-double-right"></i>
						列表
					</small>
				</h1>
				
			</div>		
			
			<div class="row">
				<div class="col-xs-12">
					
					<table id="sample-table-1" class="table table-striped table-bordered table-hover">
						<thead>
							<tr>
								<th>创建时间</th>
								<th>消息类型</th>
								<th>推送用户</th>
								<th>消息内容</th>
								<th>操作账号</th>
								<th>管理</th>
							</tr>
						</thead>

						<tbody>
							<c:forEach items="${msgs.content}" var="msg">
							<tr>
							
							    <td>
									<fmt:formatDate value="${msg.createdate}" pattern="yyyy-MM-dd HH:mm:ss" />
								</td>
								
								<td>
								       <c:choose>
											<c:when test="${msg.type eq 1}">
												消息推送
											</c:when>
											<c:when test="${msg.type eq 2}">
												消息通知
											</c:when>
											<c:when test="${msg.type eq 3}">
												维护通知
											</c:when>
											<c:otherwise>

											</c:otherwise>
										</c:choose>

								   <%--  <c:if test="${msg.deltag eq '2' }">消息推送</c:if>
									<c:if test="${msg.mode eq '1' }">普通消息</c:if>
									<c:if test="${msg.mode eq '2' }">温馨提示</c:if>
									<c:if test="${msg.mode eq '5' }">审核通过</c:if>
									<c:if test="${msg.mode eq '6' }">审核拒绝</c:if>
									<c:if test="${msg.mode eq '7' }">上传检测数据</c:if>
									<c:if test="${msg.mode eq '9' }">加盟通过</c:if> --%>
								</td>	
							
							<!-- 	<td class="center">
									<label class="position-relative">
										<input type="checkbox" class="ace" />
										<span class="lbl"></span>
									</label>
								</td> -->
<%-- 
								<td>
									<c:if test="${msg.type eq '1' }">别名</c:if>
									<c:if test="${msg.type eq '2' }">标签</c:if>
								</td>	 --%>
								
								<td>
									<c:if test="${msg.device eq '1' }">android</c:if>
									<c:if test="${msg.device eq '2' }">ios</c:if>
									<c:if test="${msg.device eq '3' }">安卓IOS</c:if>
									<c:if test="${msg.device eq '4' }">全网用户</c:if>
									<c:if test="${msg.device eq '5' }">离线用户</c:if>
								</td>	
								
								<td>
									<c:choose>  
									   <c:when test="${fn:length(msg.msg)>40}">  
									        <c:out value="${fn:substring(msg.msg, 0,40)}..."/>  
									   </c:when>  
									   <c:otherwise>  
									      <c:out value="${msg.msg}" />  
									   </c:otherwise>  
                                    </c:choose>  
								</td>	
								
							<%-- 	<td>
									<c:if test="${msg.deltag eq '0' }">正常</c:if>
									<c:if test="${msg.deltag eq '1' }">已删除</c:if>
								</td>	 --%>
								
								<td>
									${msg.userId}
								</td>	
									
								<td>
								    <a class="btn btn-xs btn-danger" href="${ctx}/msg/view/${msg.id}">
									查看
									</a>
									<!-- 
									<shiro:hasPermission name="business:message:delete	">									
										<a class="btn btn-xs btn-danger" href="${ctx}/msg/delete/${msg.id}">
											删除
										</a>
									</shiro:hasPermission>
									-->
									<c:if test="${msg.type eq 3 }">
										<a class="btn btn-xs btn-danger" href="${ctx}/msg/close/${msg.id}">
										关闭
										</a>
									</c:if>
								</td>
																	
							</tr>
							</c:forEach>
						</tbody>
					</table>
							
				</div>
			</div>
			
			<tags:pagination page="${msgs}" paginationSize="5"/>
			<shiro:hasPermission name="business:message:create">
				<div style="clear:right">
				    <a class="btn btn-info" href="${ctx}/msg/toadd">发布消息</a>
					<%-- <a class="btn btn-info" href="${ctx}/msg/createall">全体发布</a> --%>
				</div>
			</shiro:hasPermission>
			
		</div><!-- /.page-content -->
	</div>
	<script>
		$('.input-daterange').datepicker({
			format:'yyyy-mm-dd',
			autoclose:true
		});
	</script>
</body>
</html>	
